from selenium.webdriver import ActionChains

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import time
testCase = "DBshop014_删除分类流程"
# 登陆后台，点击商品管理、管理分类、商品分类
firefox=openBrowser(url)
firefox.get(urlAdmin)
DBshopLoginAdmin(firefox)
firefox.find_element_by_partial_link_text('商品管理').click()
mouse=ActionChains(firefox)
mouse.move_to_element(firefox.find_element_by_link_text("管理分类")).perform()
firefox.find_element_by_link_text('商品分类').click()
# 定位商品分类测试，点击删除分类
firefox.find_element_by_xpath("//td[contains(.,'商品分类测试')]/following-sibling::td[4]/a[3]").click()
firefox.switch_to.alert.accept()
time.sleep(20)
# 断言：找不到商品分类就测试成功
try:
    firefox.find_element_by_xpath("//td[contains(.,'商品分类测试')]").is_displayed()
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()